package com.zsw.dubbo;

import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * 
 * <p>Title: A_Logger</p>
 * <p>make模块日志 切面，对所有service包内的代理方法进行拦截，打印日志信息</p>
 * <p>Company: 科富兴</p>
 * @author    zsw
 * <p>2016年8月25日</p>
 */
@Component
@Aspect
public class A_Logger {
	
	private Logger log = Logger.getLogger(this.getClass());
	
	@Pointcut("execution(* com.zsw..service..*.*(..))" )
	private void pointcut() {}

	@Before("pointcut()")
	public void before(JoinPoint point) {}

	@AfterReturning("pointcut()")
	public void afterReturning() {}

	@After("pointcut()")
	public void after() {}

	@AfterThrowing("pointcut()")
	public void afterThrowing() {}

	/**
	 * 
	 * <p>Title: proceed</p>
	 * <p>此方法打印相关日志 </p>
	 * @param pjp
	 * @return 
	 * @throws Throwable
	 */
	@Around("pointcut()")
	@Transactional
	public Object proceed(ProceedingJoinPoint pjp) throws Throwable {
		log.info("222222222222");
		System.out.println("log");
		Object object = pjp.proceed();//执行该方法
		return object;
	}
}
